//#include "StdAfx.h"
#include "base_string.h"

CBaseStringA::CBaseStringA(void)
{
}
CBaseStringA::CBaseStringA( castr_t lpsz )
{
	m_str = lpsz;
}
CBaseStringA::CBaseStringA( astring_t & str )
{
	m_str = str;
}
CBaseStringA::CBaseStringA( CBaseStringA & str )
{
	m_str = str.m_str;
}
CBaseStringA::~CBaseStringA(void)
{
}
bool CBaseStringA::operator==( const CBaseStringA & str )
{
	return m_str == str.m_str;
}
bool CBaseStringA::operator==( const astring_t & str )
{
	return m_str == str;
}
bool CBaseStringA::operator==( castr_t lpsz )
{
	return m_str == lpsz;
}

CBaseStringA & CBaseStringA::operator=( const CBaseStringA & str )
{
	this->m_str = str.m_str;
	return *this;
}
CBaseStringA & CBaseStringA::operator=( const astring_t & str )
{
	this->m_str = str;
	return *this;
}
CBaseStringA & CBaseStringA::operator=( castr_t lpsz )
{
	this->m_str = lpsz;
	return *this;
}

int CBaseStringA::Find( castr_t lpsz, int pos )
{
	int poss = m_str.find( lpsz, pos );
	return poss;
}
int CBaseStringA::Find( const astring_t & str, int pos )
{
	int poss = m_str.find( str, pos );
	return poss;
}
int CBaseStringA::Find( const CBaseStringA & str, int pos)
{
	int poss = m_str.find( str.m_str, pos );
	return poss;
}
int CBaseStringA::Find( char ch, int pos )
{
	int poss = m_str.find( ch, pos );
	return pos;
}

void CBaseStringA::Trim()
{
	TrimLeft();
	TrimRight();
}
void CBaseStringA::TrimLeft()
{
	int begin = 0;
	size_t len = m_str.length();
	while( begin < len )
	{
		if( m_str[begin] != ' ' )
			break;
		begin++;
	}
	m_str = m_str.substr( begin );
}
void CBaseStringA::TrimRight()
{
	int begin = m_str.length();
	while( begin > 0 )
	{
		if( m_str[begin-1] != ' ' )
			break;
		begin--;
	}
	m_str = m_str.substr( 0, begin );
}

//////////////////////////////////////////////////////////////////////////
CBaseStringW::CBaseStringW(void)
{
}
CBaseStringW::CBaseStringW( cwstr_t lpsz )
{
	m_str = lpsz;
}
CBaseStringW::CBaseStringW( wstring_t & str )
{
	m_str = str;
}
CBaseStringW::CBaseStringW( CBaseStringW & str )
{
	m_str = str.m_str;
}
CBaseStringW::~CBaseStringW(void)
{
}
bool CBaseStringW::operator==( const CBaseStringW & str )
{
	return m_str == str.m_str;
}
bool CBaseStringW::operator==( const wstring_t & str )
{
	return m_str == str;
}
bool CBaseStringW::operator==( cwstr_t lpsz )
{
	return m_str == lpsz;
}

CBaseStringW & CBaseStringW::operator=( const CBaseStringW & str )
{
	this->m_str = str.m_str;
	return *this;
}
CBaseStringW & CBaseStringW::operator=( const wstring_t & str )
{
	this->m_str = str;
	return *this;
}
CBaseStringW & CBaseStringW::operator=( cwstr_t lpsz )
{
	this->m_str = lpsz;
	return *this;
}

int CBaseStringW::Find( cwstr_t lpsz, int pos )
{
	int poss = m_str.find( lpsz, pos );
	return poss;
}
int CBaseStringW::Find( const wstring_t & str, int pos )
{
	int poss = m_str.find( str, pos );
	return poss;
}
int CBaseStringW::Find( const CBaseStringW & str, int pos)
{
	int poss = m_str.find( str.m_str, pos );
	return poss;
}
int CBaseStringW::Find( wchar_t ch, int pos )
{
	int poss = m_str.find( ch, pos );
	return poss;
}

void CBaseStringW::Trim()
{
	TrimLeft();
	TrimRight();
}
void CBaseStringW::TrimLeft()
{
	int begin = 0;
	size_t len = m_str.length();
	while( begin < len )
	{
		if( m_str[begin] != L' ' )
			break;
		begin++;
	}
	m_str = m_str.substr( begin );
}
void CBaseStringW::TrimRight()
{
	int begin = m_str.length();
	while( begin > 0 )
	{
		if( m_str[begin-1] != L' ' )
			break;
		begin--;
	}
	m_str = m_str.substr( 0, begin );
}